<?php
//No direct access
defined('_JEXEC') or die('Restricted access');
?>
<div id="ownservices">
 	<div id="mainmenuownservice">
 		<?php echo MenuHelper::nav(); ?>
 	</div>
	<div id="mainownservice">
		<h3> <?php echo $this->params->get('page_title'); ?> </h3>
		<hr />
		<?php
			$priceformat 	= OwnserviceHelper::getParams('price_format', '#,###.##');
			$dateformat  	= OwnserviceHelper::getParams('date_format', '%d/%m/%Y');
			$timeformat	 	= OwnserviceHelper::getParams('time_format', '%H:%i:%s');
			$row 			= $this->row;
		?>
	<form action="index.php" method="post" id="adminForm" name="adminForm" autocomplete="off">
	<table width="100%" cellpadding="1" cellspacing="1">
	<tr>
		<td>
		<!-- sender -->
		<table class="admintable">
			<!-- detail -->
			<?php if($row->id): ?>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_RECEIVER_NO'); ?></td>
				<td>
					<?php 
						if($this->level < 5) {
							echo $row->invoice;
						} else {
							echo '<input type="text" name="invoice"  value="'.$row->invoice.'" />';
						}
					?>
				</td>
			</tr>
			<?php if( ($this->user->gid == 25) && ($this->level > 4) ) : ?>
			<tr>
				<td class="key">
					<?php echo JText::_('OWNSERVICE_STATUS'); ?>
				</td>
				<td>
					<?php echo $this->lists['status']; ?>
				</td>
			</tr>
			<?php endif; ?>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_CREATE_DATE'); ?></td>
				<td>
					<?php
						if($this->level < 5){
							echo JFactory::getDate($row->created)->toMySQL();
						} else {
							echo JHTML::calendar( $row->created, "created", "created", '%Y-%m-%d %H:%i:%s', array('class'=>'inputbox'));
						} 
					?>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_TRANSFER_ON'); ?></td>
				<td>
					<?php 
						if($this->level < 5 ){
							if($row->requested_date != $this->nullDate) {
								echo JFactory::getDate($row->requested_date)->toMySQL();
							} else{
								echo '-';
							}
						} else {
							echo JHTML::calendar( $row->requested_date, "requested_date", "requested_date", '%Y-%m-%d %H:%i:%s', array('class'=>'inputbox'));
						}
					?>
				</td>
			</tr>
			<?php endif; ?>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_SENDER'); ?> <span class="red">*</span></td>
				<td>
					<?php 
						if($row->id){
							if($this->level < 5){
								echo $row->username.' '.$this->row->name;
							} 
							else
							{
					?>
					<table>
						<tr>
							<td style="margin: 0; padding: 0;">
								<input type="text" name="membername" id="membername" value="<?php echo $row->username.' '.$this->row->name; ?>" class="inputbox" style="width:250px;" />
							</td>
							<td>
								<div class="button2-left">
									<div class="blank">
										<a class="modal" title="<?php echo JText::_('OWNS_SELECT_SENDER'); ?>" href="index.php?option=com_ownservice&amp;view=userselement&amp;tmpl=component" rel="{handler: 'iframe', size: {x:window.getSize().scrollSize.x-100, y: window.getSize().size.y-100}}">
											<?php echo JText::_('OWNS_SELECT_SENDER'); ?>
										</a>
									</div>
								</div>
							</td>
						</tr>
					</table>	
					<?php
						} 
					}
					else 
					{ 
					?>
					<table>
						<tr>
							<td style="margin: 0; padding: 0;">
								<input type="text" name="membername" id="membername" value="<?php echo $row->username.' '.$this->row->name; ?>" class="inputbox" style="width:250px;" />
							</td>
							<td>
								<div class="button2-left">
									<div class="blank">
										<a class="modal" title="<?php echo JText::_('OWNS_SELECT_SENDER'); ?>" href="index.php?option=com_ownservice&amp;view=userselement&amp;tmpl=component" rel="{handler: 'iframe', size: {x:window.getSize().scrollSize.x-100, y: window.getSize().size.y-100}}">
											<?php echo JText::_('OWNS_SELECT_SENDER'); ?>
										</a>
									</div>
								</div>
							</td>
						</tr>
					</table> 
					<?php 
					} 
					?>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_ACCOUNTS'); ?> <span class="red">*</span></td>
				<td>
					<div id="accountno"><?php echo $this->lists['account']; ?></div>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_CURRENCY'); ?> <span class="red">*</span></td>
				<td>
					<div id="currency"><?php echo $this->lists['currency']; ?></div>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_AMOUNT_TRANSFER'); ?> <span class="red">*</span></td>
				<td>
					<input type="text" name="amount" id="amount" value="<?php echo $row->amount ?>" class="inputbox required" size="10" /> AUD 
					<input type="button" name="acalculation" id="acalculate" value="<?php echo JText::_('OWNSERVICE_CALCULATE'); ?>" onClick="getTotalExchange();" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_FEE'); ?></td>
				<td>
					<input type="text" name="fee" id="fee" value="<?php echo $row->fee ?>" readonly="true" class="inputbox" size="10" /> +- <input type="text" name="extrafee" value="<?php echo $row->extrafee; ?>" class="inputbox" size="5" maxlength="5" /> AUD
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_EXCHANGE_RATE'); ?> <span class="red">*</span></td>
				<td>
					<input type="text" id="rate" name="rate" value="<?php echo $row->rate; ?>" class="inputbox required" size="10" readonly="true" /> +- <input type="text" name="extrarate" value="<?php echo $row->extrarate; ?>" class="inputbox" size="5" maxlength="5" /> 
					<span class="code"><?php echo $row->rate_code; ?></span>
				</td>
			</tr>
			<tr>
				<td class="key"> <?php echo JText::_('OWNSERVICE_DESTINATION_FEE'); ?></td>
				<td>
					<input type="text" name="bankfee" id="bankfee" value="<?php echo $row->bankfee ?>" class="inputbox" size="10" readonly="true" /> +- <input type="text" name="extrabfee" value="<?php echo $row->extrabfee; ?>" class="inputbox" size="5" maxlength="5" /> 
					<span class="code"><?php echo $row->rate_code; ?></span>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_TOTAL_EXCHANGE'); ?></td>
				<td>
					<input type="text" name="sumtotal" id="total" value="<?php echo $row->total; ?>" class="inputbox" size="10" /> 
					<span class="code"><?php echo $row->rate_code; ?></span> 
					<input type="button" name="acalculation" id="acalculate" value="<?php echo JText::_('OWNSERVICE_CALCULATE'); ?>" onClick="getTotalTransfer();" />
				</td>
			</tr>
			<tr>
				<td><?php echo JText::_('OWNSERVICE_EXTRA'); ?></td>
				<td>
					<input type="text" name="extratotal" value="<?php echo $row->extratotal; ?>" class="inputbox" size="10" /> <span class="code"><?php echo $row->rate_code; ?></span>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_REASON'); ?> </td>
				<td><?php echo $this->lists['reason']; ?></td>
			</tr>
			<tr>
				<td></td>
				<td>
					<div id="reasonother" <?php if($row->reason_other == ''): ?>style="display:none;"<?php endif; ?>>
						<input type="text" name="reason_other" value="<?php echo $row->reason_other; ?>" class="inputbox" style="width: 250px;" />
					</div>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_COMMENTS'); ?></td>
				<td><textarea name="comment" id="comment" cols="30" rows="3" class="inputbox" style="width: 250px;"><?php echo $row->comment; ?></textarea></td>
			</tr>
			<tr>
				<td colspan="2" id="otherdetail">
				<?php  if($row->amount > 10000): ?>
					<table width="100%" cellspacing="1" cellpadding="1">
						<tbody>
							<tr>
								<td class="key"><?php echo JText::_('OWNSERVICE_OCCUPATION'); ?></td>
								<td><input type="text" value="<?php echo $row->occupation; ?>" id="occupation" name="occupation"></td>
							</tr>
							<tr>
								<td class="key"><?php echo JText::_('OWNSERVICE_BIRTHDAY_RECEIVER'); ?></td>
								<td><?php echo JHTML::_('calendar', $row->birthday, 'birthday', 'birthday', '%Y-%m-%d',array('class'=>'inputbox')); ?></td>
							</tr>
						</tbody>
					</table>
				<?php endif; ?>
				</td>
			</tr>
			</table>
			</td>
			<td valign="top">
				<div id="mphoto">
					<?php if($this->image->filename): ?>
					<a class="img-preview" href="<?php echo JURI::root(true).'/'.OwnserviceHelper::getParams('path', 'images/stories/ownservices').'/'.$row->user_id.'/'.$this->image->filename ?>">
						<img src="<?php echo JURI::root(true).'/'.OwnserviceHelper::getParams('path', 'images/stories/ownservices').'/'.$row->user_id.'/'.$this->image->filename; ?>" style="border: 0; width:<?php echo $this->image->width; ?>px; height:<?php echo $this->image->height; ?>px;" />
					</a>
					<?php endif; ?>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="button" name="save" id="save" value="<?php echo JText::_('OWNSERVICE_SUBMIT'); ?>" onClick="javascript: submitbutton('save');" />
			<input type="button" name="cancel" id="cancel" value="<?php echo JText::_('OWNSERVICE_CLOSE'); ?>" onClick="javascript: submitbutton('cancel');" />
			</td>
		</tr>
		</table>
		<?php if( ($this->level < 4) ): ?>
		<input type="hidden" name="state" id="state" value="<?php echo $row->state; ?>" />
		<?php endif; ?>
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="user_id" id="user_id" value="<?php echo $row->user_id; ?>" />
		<input type="hidden" name="option" value="com_ownservice" />
		<input type="hidden" name="task" value="save" />
		<input type="hidden" name="calculate" value="0" />
		<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid'); ?>" />
		<input type="hidden" name="controller" value="transaction" />
		<input type="hidden" name="view" value="transaction" />
		<?php echo JHTML::_( 'form.token' ); ?>
		</form>

		<!-- last sender transfer -->
		<div id="lastsendertransfer"></div>
	</div>
</div>
<!-- dialog -->
<div id="dialog" title="<?php echo JText::_('OWNSERVICE_MESSAGE'); ?>" style="display: none;">
	<form name="memberform" method="post" action="<?php echo JRoute::_('index.php?option=com_ownservice'); ?>">
			<table class="admintable">
				<tr>
					<td colspan="2">
						<div id="msg"></div>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<input type="submit" value="<?php echo JText::_('OWNSERVICE_UPDATE_PROFILE'); ?>" name="updatebutton">
					</td>
				</tr>
			</table>
				<input type="hidden" value="" id="memberid" name="id">
				<input type="hidden" value="com_ownservice"  name="option" />
				<input type="hidden" value="edit" name="task">
				<input type="hidden" value="member" name="controller">
				<input type="hidden" value="member" name="view">
				<input type="hidden" value="<?php echo JRequest::getVar('Itemid'); ?>" name="Itemid">
				<?php echo JHTML::_( 'form.token' ); ?>
	</form>
</div>
<!-- max sender transfer -->
<div id="maxsendertransfer"></div>
<div id="maxreceivertransfer"></div>